<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="njtc" uri="http://www.njtcedu.cn/app/core"%>

<div id="send">
	<div class="sendBox">
		<div class="sendTitle">
			<div id="send_follow" class="mleft">有什么新鲜事与大家分享？&nbsp;&nbsp;还可以输入<span id="char_total" style="color: black;font-size: 14px;float: right">140</span>个字符</div>
			<div id="tochannel" style="display:none;">
				<textarea name="content" id="i_already">
				</textarea>
			</div>
		</div>

		<div class="sendInput" style="display:block">
			<textarea name="content" id="send_content" maxlength="148">#输入一个话题#</textarea>
		</div>

		<div class="sendInsert">
			<div class="menu_ht">
				<span  class="menu_htb_c" title="话题">话题</span>
				<span  class="menu_htb_c" title="心情">心情</span>
				<span  class="menu_htb_c"></span>
				<span id="uploadImg"><input type="file" id="fileToUpload"><a href="javaScript:void(0);">图片</a> </span>
			</div>
			
			<div class="sendBtn">
				<input type="button" class="indexBtn" id="sendMessage" value="发 布">
			</div>

		</div>
	</div>
</div>

<style>
#uploadImg{ font-size:12px; overflow:hidden; position:absolute}
#fileToUpload{ position:absolute; z-index:100; margin-left:-180px; font-size:60px;opacity:0;filter:alpha(opacity=0); margin-top:-5px;}
</style>
<script>

	$('#send_content').keydown(function(){
		var char_number = $(this).val().length;
		if (char_number <= 8　) {
			return;
		}
		
		$('#char_total').text((148-char_number));
	});
	
	$('#sendMessage').click(function(){

		var sendContent = $('#send_content').val(); 
		if (sendContent.length < 8) {
			alert("请输入你要发布的内容");
			return;
		}
		sendContent.replace();
		var rootPath = "${pageContext.request.contextPath}";
		var url = rootPath + "/content/";
		var sendDate = {sendContent:sendContent,contentType:"COMMON"};
		
		$.post(url, sendDate, function(data){
			if (data.content) {
				$.dialog({
				 	title: '系统消息',
				    icon: 'success.gif',
				    width: 200,
    				height: 100,
				    content: '发送成功'
				});
				
				var target = $('.content_scrop_list').find('li:first');
				
				var content = "<li><div class='div_left'><a href='"+ rootPath + "/home'><img src='" + rootPath + data.userImage + "'></a></div>"
								
								+"<div class='div_right'><a href='"+ rootPath + "/home'>" + data.userName +
								
								"</a>: &middot;<a href='" + rootPath + "/home'>#" +  data.topic + "#</a>" + data.content +
								
								"<div class='twit_item_time'>" + data.sendDate + "</div>" +
								
								"<div class='option'>|转发|评论</div></div></li>";
				
				target.before(content);
			}
		});
	});

</script>